﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="d" uri="/WEB-INF/resource.tld"%>

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />
<!DOCTYPE html>
<html lang="zh-CN">
<head>

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body>

	<%@ include file="/WEB-INF/include/header.jsp"%>

	<%@ include file="/WEB-INF/include/menu.jsp"%>

	<div class="container main-content">

		<div class="panel panel-default x-panel x-panel-layout">

			<div class="panel-heading">
				<ol class="breadcrumb">
					<li><a href="${ctx.host}/ecommerce">渠道管理</a></li>
					<li class="active">用户渠道统计</li>
				</ol>
			</div>

			<div class="panel-body">

				<div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
					<%@ include file="/WEB-INF/include/submenu.jsp"%>
				</div>
        <fmt:formatDate var="dateString" value="${selectDate}" pattern="yyyy-MM-dd" />
				<div class="col-xs-10 x-panel-layout-right">
  
					<div class="x-breadcrumb-wrapper">
						<div class="x-breadcrumb clearfix">
							<h2>
								<i class="glyphicon glyphicon-fire" title=""></i>&nbsp;&nbsp;<span>渠道管理&nbsp;-&nbsp;用户渠道数据</span>
							</h2>
							<div class="pull-right">
								<c:choose>
									<c:when test="${not empty currentPrincipal.site}">
										<span class="current-branchCode">${currentPrincipal.site.name}</span>
									</c:when>
									<c:otherwise>
										<select name="site">
											<option value="">所有门店</option>
											<c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
												<option value="${site.id}" ${site.id == param.site ? 'selected' : ''}>${site.name}</option>
											</c:forEach>
										</select>
									</c:otherwise>
								</c:choose>
							</div>
						</div>

						<div class="x-breadcrumb-wrapper top-margin-20" style="position: relative;">
							<fmt:formatDate value="${currentDate}" pattern="yyyy-MM-dd" var="day" />
							<ul class="nav nav-pills x-breadcrumb-nav">
								<li class="pull-left active"><a href="javascript:void(0);">
								  <fmt:formatDate value="${selectDate}" pattern="yyyy-MM" />
								</a></li>
								<div class="pull-right" style="margin-left: 15px;">
									<input type="text" class="form-control date" name="date" value="<fmt:formatDate value="${selectDate}" pattern="yyyy-MM-dd" />" data-validate="required" placeholder="请选择日期" readOnly />
								</div>
								<a href="${ctx.host}/user-source-stat/export?site=${param.site}&selectDate=${param.selectDate}" class="btn btn-default x-btn btn-shadow btn-shadow-default pull-right">导出</a>
							</ul>
						</div>

					</div>
          
          <c:forEach var="item" items="${stat}">
            <table class="table table-striped table-hover x-table table-bordered" style="margin-bottom: 20px;">
	            <thead>
	              <tr>
	                <th >${item.key}</th>
	                <th >大众点评</th>
	                <th>访客</th>
	                <th>转介绍</th>
	                <th>门店资源</th>
	                <th >线下运营</th>
	                <th >在营续课</th>
	                <th >结营续课</th>
	                <th >总计</th>
	              </tr>
	            </thead>
	            <tbody>
	              <tr>
	                <td>成单人数</td>
	                <td>${item.value[0].orderAmount}</td>
	                <td>${item.value[1].orderAmount}</td>
	                <td>${item.value[2].orderAmount}</td>
	                <td>${item.value[3].orderAmount}</td>
	                <td>${item.value[4].orderAmount}</td>
	                <td>${item.value[5].orderAmount}</td>
	                <td>${item.value[6].orderAmount}</td>
	                <td>${item.value[0].orderAmount + item.value[1].orderAmount + item.value[2].orderAmount + item.value[3].orderAmount + item.value[4].orderAmount + item.value[5].orderAmount
	                + item.value[6].orderAmount}</td>
	              </tr>
	              <tr>
	                <td>到店人数</td>
	                <td>${item.value[0].arriveAmount}</td>
	                <td>${item.value[1].arriveAmount}</td>
	                <td>${item.value[2].arriveAmount}</td>
	                <td>${item.value[3].arriveAmount}</td>
	                <td>${item.value[4].arriveAmount}</td>
	                <td>${item.value[5].arriveAmount}</td>
	                <td>${item.value[6].arriveAmount}</td>
	                <td>${item.value[0].arriveAmount + item.value[1].arriveAmount + item.value[2].arriveAmount + item.value[3].arriveAmount + item.value[4].arriveAmount + item.value[5].arriveAmount + item.value[6].arriveAmount}</td>
	              </tr>
	              <tr>
	                <td>资源人数</td>
	                <td>${item.value[0].amount}</td>
	                <td>${item.value[1].amount}</td>
	                <td>${item.value[2].amount}</td>
	                <td>${item.value[3].amount}</td>
	                <td>${item.value[4].amount}</td>
	                <td>${item.value[5].amount}</td>
	                <td>${item.value[6].amount}</td>
	                <td>${item.value[0].amount + item.value[1].amount + item.value[2].amount + item.value[3].amount + item.value[4].amount+ item.value[5].amount + item.value[6].amount}</td>
	              </tr>
	            </tbody>
	          </table>
          </c:forEach>
          
					
					

				</div>
			</div>
		</div>
	</div>

	<%@ include file="/WEB-INF/include/script.jsp"%>
	<d:resource root="${ctx.resource}/build" type="script" src="js/page/usersource/usersource-stat.js">
		<script type="text/javascript">
      require(['page/usersource/usersource-stat'], function(page) {
        page.init({
        	"date": '${dateString}',
          "site": '${selectSite.id}',
          "period": '${period}',
          "today": '${today}'
        })
      })
    </script>
	</d:resource>

</body>

</html>
